
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>通用 CRUD · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="accessor-api.html" />
    
    
    <link rel="prev" href="config-database.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../introduction/quick-start.html">
            
                <a href="../introduction/quick-start.html">
            
                    
                    快速开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../introduction/install.html">
            
                <a href="../introduction/install.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    配置
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../config/global-config.html">
            
                <a href="../config/global-config.html">
            
                    
                    全局配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../config/datasource-config.html">
            
                <a href="../config/datasource-config.html">
            
                    
                    数据源配置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    核心功能
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="config-database.html">
            
                <a href="config-database.html">
            
                    
                    添加数据源
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.2" data-path="generic-crud.html">
            
                <a href="generic-crud.html">
            
                    
                    通用 CRUD
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="accessor-api.html">
            
                <a href="accessor-api.html">
            
                    
                    Accessor API
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >通用 CRUD</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x901A;&#x7528;-crud">&#x901A;&#x7528; CRUD</h1>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x81EA;&#x5DF1;&#x7F16;&#x5199; SQL&#xFF0C;&#x4ECE;&#x800C;&#x4F7F;&#x7528; Java &#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x66F4;&#x52A0;&#x7075;&#x6D3B;&#x7684;&#x903B;&#x8F91;&#x63A7;&#x5236;&#xFF0C;&#x7136;&#x540E;&#x4F7F;&#x7528; <code>Accessor</code> API &#x53BB;&#x6267;&#x884C;&#x3002;</p>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5355;&#x8868;&#x64CD;&#x4F5C;&#x7684; API&#xFF0C;&#x50CF;&#x5199;SQL&#x4E00;&#x6837;&#x7F16;&#x5199; Java &#x4EE3;&#x7801;&#x3002;</p>
<p>&#x4F60;&#x8FD8;&#x53EF;&#x4EE5;&#x5728;&#x63A5;&#x53E3;&#x6216;&#x8005;&#x62BD;&#x8C61;&#x7C7B;&#x4E0A;&#x4F7F;&#x7528; <code>@Mapper</code> &#x6CE8;&#x89E3;&#xFF0C;&#x5728;&#x65B9;&#x6CD5;&#x4E0A;&#x4F7F;&#x7528; <code>@Execute</code> &#x6216; <code>@Select</code> &#x6267;&#x884C; CRUD &#x64CD;&#x4F5C;&#x3002;</p>
<h2 id="&#x5B9E;&#x4F53;&#x6CE8;&#x89E3;&#x8BF4;&#x660E;">&#x5B9E;&#x4F53;&#x6CE8;&#x89E3;&#x8BF4;&#x660E;</h2>
<blockquote>
<p>@Table</p>
</blockquote>
<p>&#x8868;&#x793A;&#x8BE5;&#x7C7B;&#x662F;&#x4E2A;&#x8868;&#x5B9E;&#x4F53;&#x7C7B;&#xFF0C;&#x5E76;&#x6807;&#x660E;&#x8868;&#x540D;</p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x503C;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">value</td>
<td>&#x8868;&#x540D;&#xFF0C;&#x5982;&#x679C;&#x4E3A;&#x7A7A;&#x7684;&#x8BDD;&#xFF0C;&#x5219;&#x4F7F;&#x7528;&#x5B9E;&#x4F53;&#x7C7B;&#x540D;&#x4F5C;&#x4E3A;&#x8868;&#x540D;&#xFF0C;&#x4F8B;&#xFF1A;User -&gt; user&#xFF0C;RoleAndUser -&gt; roleAndUser</td>
</tr>
</tbody>
</table>
<p>&#x6CE8;&#xFF1A;&#x5F53;&#x7136;&#x5E76;&#x4E0D;&#x4E00;&#x5B9A;&#x662F;&#x88AB; <code>@Table</code> &#x6CE8;&#x89E3;&#x7684;&#x7C7B;&#x624D;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x63A5;&#x53D7;&#x67E5;&#x8BE2;&#x7684;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#xFF0C;&#x4EFB;&#x4F55; Java Bean &#x90FD;&#x53EF;&#x4EE5;&#x3002;</p>
<blockquote>
<p>@Id</p>
</blockquote>
<p>&#x8868;&#x793A;&#x8BE5;&#x5B57;&#x6BB5;&#x4E3A;&#x8868;&#x4E2D;&#x7684;&#x4E3B;&#x952E;</p>
<table>
<thead>
<tr>
<th>&#x503C;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>value</td>
<td>&#x6307;&#x5B9A;&#x5B57;&#x6BB5;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x5982;&#x679C;&#x672A;&#x6307;&#x5B9A;&#xFF0C;&#x5219;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x8BE5;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x540D;&#x79F0;</td>
</tr>
<tr>
<td>keyGenerator</td>
<td>&#x6307;&#x5B9A;&#x4E3B;&#x952E;&#x751F;&#x6210;&#x7B56;&#x7565;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A; Snowflake &#x7B97;&#x6CD5;</td>
</tr>
</tbody>
</table>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x4E3B;&#x952E;&#x751F;&#x6210;&#x7B56;&#x7565;&#xFF1A;</p>
<ol>
<li>&#x5B9E;&#x73B0; <code>KeyGenerator&lt;T&gt;</code> &#x63A5;&#x53E3;</li>
<li>&#x7136;&#x540E;&#x5728;  <code>KeyGenerateUtil</code> &#x6CE8;&#x518C;&#x4F60;&#x7684;&#x5B9E;&#x73B0;&#x7C7B;&#xFF0C;<code>KeyGenerateUtil.registerKeyGenerator(class)</code></li>
<li>&#x4E3A;&#x4E3B;&#x952E;&#x6307;&#x5B9A; <code>keyGenerator</code>&#xFF0C;&#x6216;&#x8C03;&#x7528; <code>KeyGenerateUtil.generateId(CustomKeyGenerator.class)</code> &#x65B9;&#x6CD5;&#x751F;&#x6210;&#x552F;&#x4E00;&#x952E;&#x3002;</li>
</ol>
<blockquote>
<p>@Column</p>
</blockquote>
<p>&#x5B57;&#x6BB5;&#x6CE8;&#x89E3;</p>
<table>
<thead>
<tr>
<th>&#x503C;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>value</td>
<td>&#x6307;&#x5B9A;&#x5B57;&#x6BB5;&#x540D;&#x79F0;&#x3002;&#x5982;&#x679C;&#x672A;&#x6307;&#x5B9A;&#xFF0C;&#x5219;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x8BE5;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x540D;&#x79F0;</td>
</tr>
<tr>
<td>exists</td>
<td>&#x6307;&#x5B9A;&#x8BE5;&#x5B57;&#x6BB5;&#x662F;&#x5426;&#x5728;&#x8868;&#x4E2D;&#x5B58;&#x5728;&#x3002;&#x5982;&#x679C;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x5728;&#x4F60;&#x76F4;&#x63A5; insert(&#x5B9E;&#x4F53;&#x5BF9;&#x8C61;)&#x65F6;&#xFF0C;&#x5219;&#x4E0D;&#x4F1A;&#x89E3;&#x6790;&#x8BE5;&#x5B57;&#x6BB5;</td>
</tr>
<tr>
<td>isDictionaryKey</td>
<td>&#x6307;&#x5B9A;&#x8BE5;&#x5B57;&#x6BB5;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5B57;&#x5178;&#x5B57;&#x6BB5;&#xFF0C;true &#x8868;&#x793A;&#x5B58;&#x5728;</td>
</tr>
<tr>
<td>dictionaryClass</td>
<td>&#x5982;&#x679C;&#x8BE5;&#x5B57;&#x6BB5;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x5B57;&#x5178;&#x5B57;&#x6BB5;&#xFF0C;&#x6307;&#x5B9A;&#x6570;&#x636E;&#x5B57;&#x5178;&#x7684;&#x679A;&#x4E3E;&#x7C7B;</td>
</tr>
</tbody>
</table>
<h3 id="&#x6570;&#x636E;&#x5B57;&#x5178;">&#x6570;&#x636E;&#x5B57;&#x5178;</h3>
<p>&#x5982;&#x679C;&#x4F7F;&#x7528;&#x6570;&#x636E;&#x5B57;&#x5178;&#x529F;&#x80FD;&#xFF0C;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x5B57;&#x6BB5;&#x7684; <code>isDictionaryKey</code> &#x4E3A; <code>true</code></p>
<p>&#x5E76;&#x4E14;&#x7F16;&#x5199;&#x679A;&#x4E3E;&#x7C7B;&#x540C;&#x65F6;&#x5B9E;&#x73B0; <code>DictionaryEnum</code> &#x63A5;&#x53E3;&#x3002;</p>
<p>&#x5982;&#x679C;&#x8BE5;&#x6570;&#x636E;&#x5B57;&#x5178;&#x5B57;&#x6BB5;&#x4E3A; <code>DictionaryEnum</code> &#x7C7B;&#x578B;&#xFF0C;&#x5E76;&#x4E14;&#x6307;&#x5B9A; <code>isDictionaryKey</code> &#x4E3A; <code>true</code>&#xFF0C;&#x5219;&#x65E0;&#x9700;&#x518D;&#x6307;&#x5B9A; <code>dictionaryClass</code>&#x3002;&#x5728;&#x5904;&#x7406;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x65F6;&#xFF0C;&#x5219;&#x4F1A;&#x586B;&#x5145;&#x76F8;&#x5E94;&#x7684;&#x679A;&#x4E3E;&#x503C;&#x3002;</p>
<p>&#x5982;&#x679C;&#x5B57;&#x6BB5;&#x7684; Java &#x7C7B;&#x578B;&#x4E3A; <code>String</code> &#x7C7B;&#x578B;&#xFF0C;&#x5E76;&#x4E14;&#x6307;&#x5B9A; <code>isDictionaryKey</code> &#x4E3A; <code>true</code>&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x6307;&#x5B9A; <code>dictionaryClass</code>&#x3002;&#x5728;&#x586B;&#x5145;&#x65F6;&#x4F1A;&#x586B;&#x5145;&#x4E0A;&#x76F8;&#x5E94;&#x679A;&#x4E3E;&#x503C; &#x7684; <code>getValue()</code> &#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;</p>
<p>&#x5982;&#x679C;&#x662F;&#x5176;&#x4ED6;&#x7C7B;&#x578B;&#xFF0C;&#x5219;&#x4E0D;&#x4F1A;&#x6309;&#x7167;&#x6570;&#x636E;&#x5B57;&#x5178;&#x5B57;&#x6BB5;&#x7684;&#x903B;&#x8F91;&#x6765;&#x586B;&#x5145;&#x503C;&#x3002;</p>
<h3 id="&#x5176;&#x4ED6;&#x6CE8;&#x89E3;">&#x5176;&#x4ED6;&#x6CE8;&#x89E3;</h3>
<blockquote>
<p>@DataSource</p>
</blockquote>
<p>&#x5728;&#x4F7F;&#x7528; <code>@Select</code> &#x6216; <code>@Execute</code> &#x6CE8;&#x89E3;&#x7684;&#x65B9;&#x6CD5;&#x4E0A;&#x4F7F;&#x7528;&#x8BE5;&#x6CE8;&#x89E3;&#xFF0C;&#x6307;&#x5B9A;&#x64CD;&#x4F5C;&#x4F7F;&#x7528;&#x7684;&#x6570;&#x636E;&#x6E90;&#x3002;</p>
<table>
<thead>
<tr>
<th>&#x503C;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td>value</td>
<td>&#x6DFB;&#x52A0;&#x6570;&#x636E;&#x6E90;&#x65F6;&#x7684; tag</td>
</tr>
</tbody>
</table>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="config-database.html" class="navigation navigation-prev " aria-label="Previous page: 添加数据源">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="accessor-api.html" class="navigation navigation-next " aria-label="Next page: Accessor API">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"通用 CRUD","level":"1.4.2","depth":2,"next":{"title":"Accessor API","level":"1.4.3","depth":2,"path":"core/accessor-api.md","ref":"core/accessor-api.md","articles":[]},"previous":{"title":"添加数据源","level":"1.4.1","depth":2,"path":"core/config-database.md","ref":"core/config-database.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"core/generic-crud.md","mtime":"2019-07-26T03:00:46.480Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-26T08:30:21.431Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

